import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import pxtovw from 'postcss-px-to-viewport'
const loder_pxtovw = pxtovw({
  viewportWidth: 1920,
  viewportUnit: 'vw',
})
export default defineConfig({
  plugins: [vue()],
  css: {
    postcss: {
      plugins: [loder_pxtovw]
    }
  },

  resolve: {
    alias: {
      '@': resolve('./src')
    }
  },
  base: './', // 打包路径
  server: {
    host: true,
    port: 4000, // 前端服务端口号
    open: true, // 前端服务启动时是否自动打开浏览器
    hmr: {
      overlay: false
    },
    cors: true,// 允许跨域
    proxy: {
      '/web': {
        target: 'http://106.54.190.26:10002/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/web/, ''),
      },
      '/local': {
        target: 'http://1.8.73.111:8082/analysis/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/local/, ''),
      },
      '/files': {
        target: 'http://106.54.190.26:10002/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/files/, ''),
      },
    },
  },
})
